<!DOCTYPE html>
<html>
<head>
    <title>Azure App Service Scaling Question</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
        }
        .question {
            background-color: #f5f5f5;
            padding: 15px;
            border-radius: 5px;
            margin-bottom: 20px;
        }
        .container {
            display: flex;
            margin: 20px 0;
        }
        .actions {
            width: 40%;
            padding: 10px;
            background-color: #e9f7ef;
            border-radius: 5px;
        }
        .answer-area {
            width: 60%;
            padding: 10px;
            background-color: #e6f2ff;
            border-radius: 5px;
            min-height: 200px;
        }
        .action {
            background-color: white;
            border: 2px solid #0078d4;
            border-radius: 4px;
            padding: 8px;
            margin: 5px;
            cursor: move;
            text-align: center;
        }
        .drop-zone {
            min-height: 150px;
            border: 2px dashed #ccc;
            border-radius: 4px;
            margin: 10px 0;
            padding: 10px;
        }
        button {
            background-color: #0078d4;
            color: white;
            border: none;
            padding: 10px 15px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
        }
        button:hover {
            background-color: #106ebe;
        }
        .answer {
            margin-top: 20px;
            padding: 15px;
            background-color: #e8f5e9;
            border-radius: 5px;
            display: none;
        }
        .correct {
            color: green;
            font-weight: bold;
        }
        .possible-orders {
            margin-top: 10px;
        }
    </style>
</head>
<body>
    <div class="question">
        <h2>QUESTION NO: 107 DRAG DROP</h2>
        <p>You develop a web app that uses tier D1 app service plan by using the Web Apps feature of Microsoft Azure App Service.</p>
        <p>Spikes in traffic have caused increases in page load times.</p>
        <p>You need to ensure that the web app automatically scales when CPU load is about 85 percent and minimize costs.</p>
        <p>Which four actions should you perform in sequence? To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.</p>
        <p><strong>NOTE:</strong> More than one order of answer choices is correct. You will receive credit for any of the correct orders you select.</p>
        
        <div class="container">
            <div class="actions" id="actionsList">
                <h3>Actions</h3>
                <div class="action" draggable="true" id="configurePremium">Configure the web app to the Premium App Service tier.</div>
                <div class="action" draggable="true" id="configureStandard">Configure the web app to the Standard App Service tier.</div>
                <div class="action" draggable="true" id="enableAutoscaling">Enable autoscaling on the web app.</div>
                <div class="action" draggable="true" id="addScaleRule">Add a Scale rule.</div>
                <div class="action" draggable="true" id="switchConsumption">Switch to an Azure App Services consumption plan.</div>
                <div class="action" draggable="true" id="configureCondition">Configure a Scale condition.</div>
            </div>
            
            <div class="answer-area">
                <h3>Answer Area</h3>
                <div class="drop-zone" id="answerDropZone"></div>
            </div>
        </div>
        
        <button id="showAnswer">查看答案</button>
        
        <div id="answerSection" class="answer">
            <p><span class="correct">正确答案:</span></p>
            <div class="possible-orders">
                <p><strong>可能的正确顺序之一:</strong></p>
                <ol>
                    <li>Configure the web app to the Standard App Service tier.</li>
                    <li>Enable autoscaling on the web app.</li>
                    <li>Configure a Scale condition.</li>
                    <li>Add a Scale rule.</li>
                </ol>
                <p><strong>另一个可能的正确顺序:</strong></p>
                <ol>
                    <li>Configure the web app to the Standard App Service tier.</li>
                    <li>Enable autoscaling on the web app.</li>
                    <li>Add a Scale rule.</li>
                    <li>Configure a Scale condition.</li>
                </ol>
            </div>
            <p><strong>说明:</strong></p>
            <p>要实现基于CPU负载(85%)的自动扩展并最小化成本，正确的步骤包括：</p>
            <ol>
                <li>首先将Web应用升级到Standard或更高层级的服务计划(因为D1层不支持自动扩展)</li>
                <li>启用自动扩展功能</li>
                <li>配置扩展条件(设置CPU阈值85%)</li>
                <li>添加扩展规则</li>
            </ol>
            <p>注意：Premium层级虽然支持自动扩展，但成本较高；Consumption计划(无服务器)虽然成本低，但不适用于此场景，因为题目中已经使用了App Service计划。</p>
            <p>参考文档: <a href="https://docs.microsoft.com/en-us/azure/azure-monitor/platform/autoscale-get-started" target="_blank">Azure自动扩展文档</a></p>
        </div>
    </div>

    <script>
        // Drag and drop functionality
        const actions = document.querySelectorAll('.action');
        const answerDropZone = document.getElementById('answerDropZone');
        
        actions.forEach(action => {
            action.addEventListener('dragstart', () => {
                action.classList.add('dragging');
            });
            
            action.addEventListener('dragend', () => {
                action.classList.remove('dragging');
            });
        });
        
        answerDropZone.addEventListener('dragover', e => {
            e.preventDefault();
            answerDropZone.classList.add('hover');
        });
        
        answerDropZone.addEventListener('dragleave', () => {
            answerDropZone.classList.remove('hover');
        });
        
        answerDropZone.addEventListener('drop', e => {
            e.preventDefault();
            answerDropZone.classList.remove('hover');
            
            const action = document.querySelector('.dragging');
            if (action && answerDropZone.querySelectorAll('.action').length < 4) {
                const clone = action.cloneNode(true);
                clone.setAttribute('draggable', 'false');
                answerDropZone.appendChild(clone);
            }
        });
        
        // Show answer button
        document.getElementById('showAnswer').addEventListener('click', function() {
            const answerSection = document.getElementById('answerSection');
            answerSection.style.display = answerSection.style.display === 'none' ? 'block' : 'none';
        });
    </script>
</body>
</html>
